function dealTime() {
    let h1 = app.startTime1.getHours(); let m1 = app.startTime1.getMinutes(); let s1 = app.startTime1.getSeconds();
    let h2 = app.startTime2.getHours(); let m2 = app.startTime2.getMinutes(); let s2 = app.startTime2.getSeconds();
    let h3 = app.startTime3.getHours(); let m3 = app.startTime3.getMinutes(); let s3 = app.startTime3.getSeconds();
    let h11 = app.endTime1.getHours(); let m11 = app.endTime1.getMinutes(); let s11 = app.endTime1.getSeconds();
    let h21 = app.endTime2.getHours(); let m21 = app.endTime2.getMinutes(); let s21 = app.endTime2.getSeconds();
    let h31 = app.endTime3.getHours(); let m31 = app.endTime3.getMinutes(); let s31 = app.endTime3.getSeconds();
    return h1 + "-" + m1 + "-" + s1 + "-" + h2 + "-" + m2 + "-" + s2 + "-" + h3 + "-" + m3 + "-" + s3 +
    "-" + h11 + "-" + m11 + "-" + s11 + "-" + h21 + "-" + m21 + "-" + s21 + "-" + h31 + "-" + m31 + "-" + s31;
}

function dealTimeNew(channelType) {
    if (channelType == "28"){
        let h = app.startTime1.getHours(); let m = app.startTime1.getMinutes(); let s = app.startTime1.getSeconds();
        let h1 = app.endTime1.getHours(); let m1 = app.endTime1.getMinutes(); let s1 = app.endTime1.getSeconds();
        return h + "-" + m + "-" + s + "-" + h1 + "-" + m1 + "-" + s1 ;
    }else if (channelType == "2E"){
        let h = app.startTime2.getHours(); let m = app.startTime2.getMinutes(); let s = app.startTime2.getSeconds();
        let h1 = app.endTime2.getHours(); let m1 = app.endTime2.getMinutes(); let s1 = app.endTime2.getSeconds();
        return h + "-" + m + "-" + s + "-" + h1 + "-" + m1 + "-" + s1 ;
    }else{
        let h = app.startTime3.getHours(); let m = app.startTime3.getMinutes(); let s = app.startTime3.getSeconds();
        let h1 = app.endTime3.getHours(); let m1 = app.endTime3.getMinutes(); let s1 = app.endTime3.getSeconds();
        return h + "-" + m + "-" + s + "-" + h1 + "-" + m1 + "-" + s1 ;
    }
}

function handleSetScale1(channel , scaleStr , deviceVo){
    $axios({
        url: "/resistance/operation/old/setScale/" + scaleStr + "/" + channel,
        method: 'post',
        data: deviceVo
    }).then((res) => {
        if (res.code === 0) {
            app.$message({ type: 'success', message: res.msg });
        } else {
            app.$message.error(res.msg);
        }
    });
}

function handleSetWorkTime1(deviceVo) {
    $axios({
        url: "/resistance/operation/old/setWorkTime/" + dealTime(),
        method: 'post',
        data: deviceVo
    }).then((res) => {
        if (res.code === 0) {
            app.$message({ type: 'success', message: res.msg });
        } else {
            app.$message.error(res.msg);
        }
    });
}

function handleTime1(deviceVo) {
    $axios({
        url: "/resistance/operation/old/setTime",
        method: 'post',
        data: deviceVo
    }).then((res) => {
        if (res.code === 0) {
            app.$message({ type: 'success', message: res.msg });
        } else {
            app.$message.error(res.msg);
        }
    });
}

function handleScreenOn1(status , deviceVo) {
    let ss = "";
    if (status === "00") {
        ss = "打开";
    } else if (status === "01") {
        ss = "关闭";
    }
    $axios({
        url: "/resistance/operation/old/screenOn/" + status,
        method: 'post',
        data: deviceVo
    }).then((res) => {
        if (res.code === 0) {
            app.$message({ type: 'success', message: res.msg });
        } else {
            app.$message.error(res.msg);
        }
    });
}

function handleTime2(deviceVo) {
    $axios({
        url: "/resistance/operation/setTime",
        method: 'post',
        data: deviceVo
    }).then((res) => {
        if (res.code === 0) {
            app.$message({ type: 'success', message: res.msg });
        } else {
            app.$message.error(res.msg);
        }
    });
}

function newLockKey1(deviceVo , status) {
    $axios({
        url: "/resistance/operation/lockKey/"+ status,
        method: 'post',
        data: deviceVo
    }).then((res) => {
        if (res.code === 0) {
            app.$message({ type: 'success', message: res.msg });
        } else {
            app.$message.error(res.msg);
        }
    });
}
// 红外感应开关
function newInfraredOn1(deviceVo , status) {
    $axios({
        url: "/resistance/operation/infrared/"+ status,
        method: 'post',
        data: deviceVo
    }).then((res) => {
        if (res.code === 0) {
            app.$message({ type: 'success', message: res.msg });
        } else {
            app.$message.error(res.msg);
        }
    });
}
function handleSetScale2(channelType , scaleStr , deviceVo){
    $axios({
        url: "/resistance/operation/setScale/"+ scaleStr + "/" + channelType ,
        method: 'post',
        data: deviceVo
    }).then((res) => {
        if (res.code === 0) {
            app.$message({ type: 'success', message: res.msg });
        } else {
            app.$message.error(res.msg);
        }
    });
}

function handleSetWorkTime2( channelType , deviceVo) {
    $axios({
        url: "/resistance/operation/setWorkTime/"+ channelType + "/" + dealTimeNew(channelType),
        method: 'post',
        data: deviceVo
    }).then((res) => {
        if (res.code === 0) {
            app.$message({ type: 'success', message: res.msg });
        } else {
            app.$message.error(res.msg);
        }
    });
}